You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

32 lines
828 B

import { requireAdmin } from "#server/utils/admin-guard";
import { updateAgentTool } from "#server/service/agent-tool";
export default defineWrappedResponseHandler(async (event) => {
await requireAdmin(event);
const id = getRouterParam(event, "id");
if (!id) {
return R.throwError(400, "无效的工具ID", null);
}
const body = await readBody(event);
const { name, slug, description, type, config, enabled, sortOrder } = body;
try {
const result = await updateAgentTool(id, {
name,
slug,
description,
type,
config,
enabled,
sortOrder,
});
if (!result) {
return R.throwError(404, "工具不存在", null);
}
return R.success(result);
} catch (e) {
return R.throwError(400, e instanceof Error ? e.message : String(e), null);
}
});